package com.luojing.springcloud.service;

import com.luojing.springcloud.config.orderdelay.OrderDelayMsg;
import com.luojing.springcloud.config.orderdelay.OrderDelayQueue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author luojing
 * @create 2018/10/29 9:25 AM
 **/
@Service
public class OrderService {
  @Autowired
  private OrderDelayQueue orderDelayQueue;

  public void orderStatusDelay() throws InterruptedException {
    // TODO: 2018/10/29 获取订单id,判断状态是否和队列中状态一致,如果一致则执行对应操作
    OrderDelayMsg orderDelayMsg = orderDelayQueue.get();

    //数据库查询
    String nowStatus = "1";
    String msgStatus = orderDelayMsg.getOrderStatus();

    if(nowStatus.equals(msgStatus)){
      //更新订单状态为目标状态

      System.out.println("成功消费订单" + orderDelayMsg.getOrderId());
    }

  }
}
